﻿using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace TodoApp.EntityFrameworkCore.EntityConfigurations.Todos
{
    public class TodoEntityTypeConfiguration : IEntityTypeConfiguration<Todo>
    {
        public void Configure(EntityTypeBuilder<Todo> builder)
        {
            builder.ToTable("Todo");
            builder.HasKey(x => x.Id);

            builder.Property(x => x.Content).HasMaxLength(500);
            builder.Property(x => x.CreationTime).HasValueGenerator<CreationTimeValueGenerator>();

            builder.Property(x => x.IsDeleted).HasComment("是否已删除");
        }
    }
}
